package com.foxzzz.temporary;

import com.foxzzz.base.ArrayUtil;

public class Solution1103 {

    public int[] distributeCandies(int candies, int num_people) {
        int[] array = new int[num_people];
        int shouldGivenNum = 1;
        int index = 0;
        while (true) {
            if (candies - shouldGivenNum > 0) {
                array[index] = array[index] + shouldGivenNum;
            } else {
                array[index] = array[index] + candies;
                break;
            }
            candies -= shouldGivenNum;
            shouldGivenNum++;
            index = (index + 1) % num_people;
        }
        return array;
    }

    public static void main(String[] args) {
        Solution1103 solution1103 = new Solution1103();
        int[] ints = solution1103.distributeCandies(7, 4);
        ArrayUtil.visit(ints);
    }
}
